USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[KyogiFlg]    Script Date: 04/24/2014 13:41:56 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[KyogiFlg]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[KyogiFlg]
GO

USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[KyogiFlg]    Script Date: 04/24/2014 13:41:56 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[KyogiFlg]
(
	@HOST VARCHAR(10),
	@KYOGIFLG INT
)
RETURNS varchar
AS
BEGIN
	DECLARE @return varchar(10)
	--IF (@KYOGIFLG > 0) AND (@HOST !='' or @HOST != null)
	IF (@KYOGIFLG > 0) AND (@HOST !='' or @HOST IS NOT NULL)
		SET @return = @HOST
	ELSE
		BEGIN
	select @return = MSG.TITLE from TBL_WEB_USE_ID ID,TBL_WEB_USE_MSG MSG
	WHERE LOWER(TAGNAME)=LOWER('EventState') 
	AND ID.TAGID=MSG.TAGID
	AND MSG.XMLCODE=@KYOGIFLG
			
/*
	ELSE IF @KYOGIFLG = 1
		SET @return = '確定'
	ELSE IF @KYOGIFLG = 2
		SET @return = '全済'
	ELSE IF @KYOGIFLG = 6
		SET @return = ''
	ELSE IF @KYOGIFLG = 7
		SET @return = '審議中'
	ELSE IF @KYOGIFLG = 9
		SET @return = '入力中'
	ELSE IF @KYOGIFLG = 10
		SET @return = '入力済'
	ELSE IF @KYOGIFLG = 11
		SET @return = '入力中'
	ELSE 
		SET @return = ''
*/
		END
	RETURN @return
END
GO

